# Contributor: Raphael Cohn <raphael.cohn@stormmq.com>
# Contributor: prez <prez@national.shitposting.agency>
# Maintainer: Raphael Cohn <raphael.cohn@stormmq.com>
pkgname=hitch
pkgver=1.7.2
pkgrel=0
pkgdesc="hitch is a TLS / SSL endpoint like stunnel"
url="https://hitch-tls.org/"
arch="all"
license="BSD-2-Clause"
makedepends="libev-dev openssl1.1-compat-dev py3-docutils bison flex"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://hitch-tls.org/source/hitch-$pkgver.tar.gz
	hitch.initd
	hitch.confd
	hitch.conf
	"

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-tcp-fastopen
	make
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm755 "$srcdir/$pkgname.initd" "$pkgdir/etc/init.d/$pkgname"
	install -Dm644 "$srcdir/$pkgname.confd" "$pkgdir/etc/conf.d/$pkgname"
	install -Dm644 "$srcdir/$pkgname.conf" "$pkgdir/etc/$pkgname/hitch.conf"

	mkdir -p "$pkgdir"/usr/share/doc/$pkgname/examples/
	install -m644 hitch.conf.example \
		"$pkgdir"/usr/share/doc/$pkgname/examples/
}

sha512sums="
7b35b5f4a3b6dab2599643c0bc90880a77ea518a627b31813f45a7ee8c52982ba4ac07228b640a0bcf90ea7d63421b62884a091fed6664732585585e5ec15bcf  hitch-1.7.2.tar.gz
afc98a8422199c1c64eeab10e718b71af419f5d4bad692d1e23f539f75d6dcb5efe6dbee21517854254a57075ad8273760602f5cb2f0dbcd00fa1d877ea4ce63  hitch.initd
fee3910d0a3d5b6b34712bfc9a4f56ae316c974ea28991ca2466ed372802e564eee82f6e8af87e73597f66a8f1d2bc0e1a303164e1db51ce90c4bbb68ea6f2da  hitch.confd
c2db10a0fec44958f9e3056b013743b4f6c4d0aa21e030120bf7e2f9a3941e276ca1f85ab2a1c051ac17aacd857cae13f308f4d192edc61b2322ab9dbe99f99c  hitch.conf
"
